import { getLevelSecond, getPosIDs, getUserID } from '@/utils';

/**
 * 切换列表
 * @param curRes 权限数据
 * @returns
 */
const HomeTaskTabSwitch = (curRes: Record<string, any>, taskType?: boolean) => {
  /**
   * 待办还是已办
   * @taskType  true :已办   false : 待办
   */
  if (curRes?.['/contractController/taskManage/0/0']) {
    return {
      dealState: taskType,
      sort: taskType ? 'END_TIME_' : 'CREATE_TIME_',
      queryType: '0',
      params: 'ownCompanyID',
    };
  } else if (curRes?.['/contractController/taskManage/0/1']) {
    return {
      assigneePositionID: getLevelSecond(),
      dealState: taskType,
      sort: taskType ? 'END_TIME_' : 'CREATE_TIME_',
      queryType: '1',
      params: 'ownDepartmentID',
    };
  } else if (curRes?.['/contractController/taskManage/0/2']) {
    return {
      assigneePositionID: getPosIDs(),
      queryType: '2',
      params: 'ownerID',
    };
  } else {
    return {};
  }
};

/** 权限信息 */
const getHomeTabSwitch = (curRes: Record<string, any>) => {
  // if (curRes?.['/contractController/ownCompanyID']) {
  //   return {
  //     ownCompanyID: getLevelZero(),
  //     params: 'ownCompanyID',
  //   };
  // } else if (curRes?.['/contractController/ownDepartmentID']) {
  //   return {
  //     ownDepartmentID: getLevelFirst(),
  //     params: 'ownDepartmentID',
  //   };
  // } else
  if (curRes?.['/contractController/ownerID']) {
    return {
      ownerID: getUserID(),
      params: 'ownerID',
    };
  }
  return {};
};

export { HomeTaskTabSwitch, getHomeTabSwitch };
